-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ft/timestamp validation class #446
Conversation
const dateTime = momentTimeZone.tz(ele[key], measurements.timezone); | ||
let milliSeondsToAddSentInRequest = ''; | ||
if ( | ||
ele[key].toString().includes('.') && | ||
!isNaN( | ||
parseInt( | ||
ele[key] | ||
.toString() | ||
.substring( | ||
ele[key].toString().indexOf('.'), | ||
ele[key].toString().length, | ||
), | ||
), | ||
) | ||
) { | ||
milliSeondsToAddSentInRequest = ele[key] | ||
.toString() | ||
.substring( | ||
ele[key].toString().indexOf('.'), | ||
ele[key].toString().length, | ||
); | ||
} | ||
let utcString: string = dateTime.clone().utc().format(); | ||
|
||
if (milliSeondsToAddSentInRequest != '') { | ||
utcString = | ||
utcString.substring(0, utcString.length - 1) + | ||
milliSeondsToAddSentInRequest + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seem like we don't need this codes.
|
||
return value.every((ele) => { | ||
const startTimestamp = ele.starttimestamp; | ||
const endTimestamp = ele.endtimestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should validate the timestamp individually
/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.{0,1}\d{0,3}Z?$/; | ||
|
||
return value.every((ele) => { | ||
const startTimestamp = ele.starttimestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wouldn't work. Here were are assuming that we are validating an object which contains both the startTimestmap
and endTimestamp
which is not the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@musayann I did so because there will be a time when we will validate both, mainly history read
, and when it's only one of them validate it alone. So, I am not getting what you mean here. I am probably missing something out. May you provide more clarification?
} else { | ||
utcString = | ||
utcString.substring(0, utcString.length - 1) + '.000Z'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is not implemented. We should have a transformer for it
930ca1e
to
5fac77d
Compare
5fac77d
to
06d276b
Compare
Created meter read timestamp custom validation
Issue ticket #444 and link
Checklist before requesting a review